home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / dosutils / tsbat50.zip / PROMPT.TXT < prev    next >
Internet Message Format  |  1996-05-26  |  6KB

  1. From ts@uwasa.fi Sun May 26 00:00:00 1996
  2. Subject: Prompt file information
  3.  
  4. PROMPT.TXT prompt and related tips                   Sun 26-May-1996
  5. ==================================
  6.                                                  All rights reserved
  7.                                Copyright (c) 1993-1996 by Timo Salmi
  8.  
  9. ....................................................................
  10. Prof. Timo Salmi   Co-moderator of news:comp.archives.msdos.announce
  11. Moderating at ftp:// & http://garbo.uwasa.fi archives  193.166.120.5
  12. Department of Accounting and Business Finance  ; University of Vaasa
  13. ts@uwasa.fi http://uwasa.fi/~ts BBS 961-3170972; FIN-65101,  Finland
  14. ....................................................................
  15.  
  16.   ┌───────────────────────────────────────────────────────────┐
  17.   │ This file belongs to TSBAT*.ZIP. Please do not distribute │
  18.   │ this prompt.txt file separately! If you see this file     │
  19.   │ alone on a BBS, please alert the SysOp immediately.       │
  20.   └───────────────────────────────────────────────────────────┘
  21.  
  22. --------------------------------------------------------------------
  23.  
  24. From ts@uwasa.fi Sun May 26 00:00:01 1996
  25. Subject: Changing the shell prompt
  26.  
  27. 1) If you have programs that can shell to dos it would be nice to
  28. know whether you currently are in a dos shell or not. Else you might
  29. call the same program again from the shell and eventually run out of
  30. memory. There is a rather straight-forward trick for this. Assume
  31. that your program is called prog.exe. You can always call the
  32. program from a batch, say pro.bat. Include the following lines in
  33. your batch:
  34.  
  35.   set _prompt=%prompt%
  36.   set prompt=%_prompt%[in shell or whatever text]
  37.   prog %1 %2 %3 %4 %5 %6 %7 %8 %9
  38.   set prompt=%_prompt%
  39.   set prompt=
  40.  
  41. The method will not work or will produce unexpected results if the
  42. program itself manipulates the prompt when shelling to Dos. Some
  43. (usually advanced) programs do.
  44.  
  45. Another trick to avoid double loading is shown in the following
  46. skeleton
  47.   if "%_loaded%"=="yes" exit
  48.   set _loaded=yes
  49.   prog %1 %2 %3 %4 %5 %6 %7 %8 %9
  50.   set _loaded=
  51. --------------------------------------------------------------------
  52.  
  53. From ts@uwasa.fi Sun May 26 00:00:02 1996
  54. Subject: Redefining keys
  55.  
  56. 2) A frequently asked question about ansi.sys is now does one use it
  57. to redefine keyboard keys. Here is an example which redefines the F1
  58. key invoke the directory "dir" command, the F2 key to invoke the
  59. "dir/w" command, and the F3 to type the Scandinavian letter ä.
  60.    prompt $e[0;59;"dir";13p
  61.    prompt $e[0;60;"dir/w";13p
  62.    prompt $e[0;61;"ä"p
  63.    prompt $p$g
  64.  
  65. The last line is needed to restore the prompt in its usual format
  66. (which I have as $p$g).
  67.  
  68. To cancel the definitions apply
  69.    prompt $e[0;59;;p
  70.    prompt $e[0;60;;p
  71.    prompt $e[0;61;;p
  72.    prompt $p$g
  73.  
  74. This system requires that you have ansi.sys loaded in your
  75. config.sys file
  76.    device=c:\dos\ansi.sys
  77.  
  78. A related FAQ (Frequently Asked Question) is how to exchange the .
  79. and , keys.  here is how to do that
  80.   @echo <ESC>[",";"."p<ESC>[".";","p
  81. To reverse the effect, apply
  82.   @echo <ESC>[",";","p<ESC>[".";"."p
  83. This trick will not work for exchanging the CTRL and SHIFT keys.
  84. They are not mappable this way.
  85.  
  86. Note that ansi.sys replacements like zansi.sys (which I normally use
  87. myself) do not have the key-redefinition feature. This has one
  88. advantages, that is protecting you against the so-called ansi bombs.
  89.  
  90. The 0;59 pair defines F1 because it is that key's scan code. To get
  91. the scan codes of the different keys you need either a scan code
  92. table or a program that gives the scan code of the key you have
  93. pressed. One such program is SCANCODE.EXE. You can find it is
  94. ftp://garbo.uwasa.fi/pc/ts/tsbase12.zip (or whatever version number
  95. is the current).
  96. --------------------------------------------------------------------
  97.  
  98. From ts@uwasa.fi Sun May 26 00:00:03 1996
  99. Subject: Ansi prompt art
  100.  
  101. 3) You can devise quite complicated ansi prompts to do flashy
  102. things although much of this is rather computer entertainment than
  103. serious usage. Let look at some examples
  104.  
  105. My ordinary prompt is the simple
  106.    prompt $p$g
  107. which displays the directory followed bu the > sign. Furthermore I
  108. use bright yellow on black, but for that I apply echo <ESC>[40;33;1m
  109.  
  110. Let's build from that.
  111.    prompt $d $t$_$p$g
  112. Gives the date and the time on the first line ($d $t), then on the
  113. second ($_) gives the current directory ($p) and the > sign ($g).
  114.  
  115. Lets take a little more complicated example next:
  116.    prompt $e[s$e[1;69H$t$h$h$h$e[u$p$g
  117. To also include the date use:
  118.    prompt $e[s$e[1;54H$d$e[1;69H$t$h$h$h$e[u$p$g
  119. This is of of the basic prompt tricks, and it puts the time (and
  120. date) in the upper right corner of the screen. First the current
  121. cursor position is stored ($e[s); the cursor is moved to row 1,
  122. column 69 ($e[1;69H) the time is displayed ($t); the hundredths of a
  123. second are deleted ($h$h$h); the original cursor position is
  124. restored ($e[u); and finally the current directory and the > sign
  125. are displayed ($p$g).
  126.  
  127. The next obvious step is to display the time in some garish reverse.
  128. For the normal part of the prompt lets use my own default which is
  129. bright yellow on black ($e[40;33;1m).
  130.    prompt $e[s$e[1;69H$e[41;32;1m$t$e[40;33;1m$h$h$h$e[u$p$g
  131. The time is displayed in bright green on red ($e[41;32;1m).
  132.  
  133. The interpretation of the following prompt is left as an exercise:
  134.    prompt $e[s$e[H$e[43;30m$e[KDirectory $p $d $t $h$h$h$h $v
  135.           $e[40;33;1m$e[2;1H$e[K$e[u$p$g
  136. Note that you must have everything on one line only. The wrap here
  137. is just for readability.
  138.  
  139. One example of an "entertainment" prompt just to give the general
  140. idea:
  141.    prompt $e[s$_$e[40;37m██$e[34m██$e[37m████$_$e[34m████████
  142.           $e[40;37m$_██$e[34m██$e[37m████$e[40;33m $p$g
  143. Note that you must have everything on one line only. The wrap here
  144. is just for readability.
  145.  
  146. The difference in using the echo and the prompt for setting the
  147. screen colors is that the echo is invoked only when you apply it,
  148. but the prompt is called each time the dos prompt appears.
  149. --------------------------------------------------------------------
  150.  
  151. From ts@uwasa.fi Sun May 26 00:00:04 1996
  152. Subject: Debugging the prompt
  153.  
  154. 4) If you are having problems you can "debug" your prompt by giving
  155. the set command in MS-DOS which displays your environment variables
  156. including the prompt variable.
  157.